﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ArchivesAdmin.Admin.Web.Controllers;
using ArchivesAdmin.Business.TrainingManage;
using ArchivesAdmin.Entity.TrainingManage;
using ArchivesAdmin.Model.Param.TrainingManage;
using ArchivesAdmin.Util.Model;
using ArchivesAdmin.Web.Code;
using Microsoft.AspNetCore.Mvc;

namespace ArchivesAdmin.Admin.Web.Areas.DataManage.Controllers
{
    [Area("DataManage")]
    public class BackupController : BaseController
    {
        private TeacherBLL teacherBLL = new TeacherBLL();

        #region 视图功能
        //[AuthorizeFilter("Training:teacher:view")]
        public IActionResult Index(int id)
        { 
            return View();
        }

        public IActionResult TeacherDetail()
        {
            return View();
        }

        public async Task<IActionResult> TeacherForm()
        {
            ViewBag.OperatorInfo = await Operator.Instance.Current();
            return View();
        }
        #endregion

        #region 获取数据
        [HttpGet]
        //[AuthorizeFilter("Training:teacher:search")]
        public async Task<IActionResult> GetListJson(TeacherListParam param)
        {
            TData<List<TeacherEntity>> obj = await teacherBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        //[AuthorizeFilter("Training:teacher:search")]
        public async Task<IActionResult> GetPageListJson(TeacherListParam param, Pagination pagination)
        {
            TData<List<TeacherEntity>> obj = await teacherBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<IActionResult> GetFormJson(long id)
        {
            TData<TeacherEntity> obj = await teacherBLL.GetEntity(id);
            return Json(obj);
        }
 
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("archive:archive:add")]
        public async Task<IActionResult> SaveFormJson(TeacherEntity entity)
        {
            TData<string> obj = await teacherBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("training:teacher:delete")]
        public async Task<IActionResult> DeleteFormJson(string ids)
        {
            TData obj = await teacherBLL.DeleteForm(ids);
            return Json(obj);
        }
          
        #endregion

    }
     
}